package com.example.demo.domain.exam;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.example.demo.annotation.Display;
import com.example.demo.enums.ExamStatus;
import com.example.demo.enums.ExamType;
import com.example.demo.enums.LanguageType;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import lombok.Data;
import lombok.RequiredArgsConstructor;
import org.springframework.format.annotation.DateTimeFormat;

import java.sql.Timestamp;

/**
 * 考试信息
 */
@Data
@RequiredArgsConstructor
@TableName(value = "exam")
public class Exam {

    @Display("考试标识")
    // 测试
    @JsonSerialize(using = ToStringSerializer.class)
    @TableId(value = "id", type = IdType.ASSIGN_ID)
    private Long id;

    @Display("考试名词")
    @TableField(value = "exam_name")
    private String examName;

    @Display("考试所属班级标识")
    @TableField(value = "class_id")
    @JsonSerialize(using = ToStringSerializer.class)
    private Long classId;

    @Display("班级名称")
    @TableField(exist = false)
    private String className;

    @Display("公司所属标识")
    @TableField(value = "company_id")
    @JsonSerialize(using = ToStringSerializer.class)
    private Long companyId;

    @Display("公司名称")
    @TableField(exist = false)
    private String companyName;

    @Display("试卷标识")
    @TableField(value = "paper_id")
    @JsonSerialize(using = ToStringSerializer.class)
    private Long paperId;

    @Display("试卷名称")
    @TableField(exist = false)
    private String paperName;

    @Display("开始时间")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @TableField(value = "start_time")
    private Timestamp startTime;

    @Display("结束时间")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @TableField(value = "end_time")
    private Timestamp endTime;

    @Display("创建人标识")
    @TableField("creator_id")
    @JsonSerialize(using = ToStringSerializer.class)
    private Long creatorId;

    @Display("考试类型")
    @TableField("duration_time")
    private Long durationTime;

    @Display("考试类型")
    @TableField("exam_type")
    private ExamType examType;

    @Display("考试状态")
    @TableField("exam_status")
    private ExamStatus examStatus;

    @Display("选择语言类型")
    @TableField("language_type")
    private LanguageType languageType;

    @Display("创建时间")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @TableField(value = "create_time")
    private Timestamp createTime;

    @Display("是否禁用")
    @TableField(value = "disabled")
    private Boolean disabled;

    @Display("实到人数")
    @TableField(value = "attend_num")
    private Integer attendNum;

    @Display("应到人数")
    @TableField(value = "applicant_num")
    private Integer applicantNum;

    @Display("个人考试情况")
    @TableField(exist = false)
    private ExamUserScore userScore;

}
